import React, {useEffect, useState} from 'react';
import {getChannels} from "../../api/publish";
import {Select} from "antd";
const { Option } = Select

function Channels({value,onChange}) {
    const [list,setList]=useState([])
    useEffect(()=>{
        getChannels().then((res)=>{
            // console.log(res)
            if (res.message==='OK'){
                setList([...res.data.channels])
            }
        })
    },[])
    return (
       <Select
           placeholder='选择频道'
           value={value}
           onChange={onChange}
       >
               {list.map(item => (
                   <Option key={item.id} value={item.id}>
                       {item.name}
                   </Option>
               ))}
       </Select>
    );
}

export default Channels;
